package initialize

import (
	"fmt"
	"github.com/hibiken/asynq"
	"reward-server/global"
)

func DelayQueueInit() {

	srv := asynq.NewServer(
		asynq.RedisClientOpt{
			Addr:     fmt.Sprintf("%v:%v", global.ServerConfig.Redis.Host, global.ServerConfig.Redis.Port), //"127.0.0.1:6379",
			Password: global.ServerConfig.Redis.PassWord,
			DB:       global.ServerConfig.Redis.IndexDB,
			Username: global.ServerConfig.Redis.Username,
		},
		asynq.Config{
			// 每个进程并发执行的worker数量
			Concurrency: 5,
			Queues: map[string]int{
				"critical": 6,
				"default":  3,
				"low":      1,
			},
		},
	)
	mux := asynq.NewServeMux()
	//mux.HandleFunc(global.TypeTaskPushDelivery, tickets.ResetTickets)

	if err := srv.Run(mux); err != nil {
		panic(err)
	}

}
